## 模板1
import os

env = None
# 1.编译器
if os.system("which clang"):
    env = Environment()
else:
    # clang编译器
    env = Environment(tools=["default", "clang"])
    env["CC"] = ["clang"]
    env["CXX"] = ["clang++"]

env["PROGSUFFIX"] = ".out"  # 可执行后缀.out
env["CCFLAGS"] = " -ggdb3 -O0 -Wall"  # gdb 调试开关
src_list = [
    "1_fread_fwrite_文件复制_copy.c",
    "2_printf_打印2_8_10_16进制.c",
    "6.1_fseek_通过偏移_赋值文件.c",
    # "7_ftell_获取当前文件位置.c",
    "7.1_ftell_获取文件大小.c",
    "13_fopen_fwrite_文件覆盖写入.c",
]

for src in src_list:
    env.Program(Split(src))

obj_img = "test.img"
if not os.path.exists(obj_img):
    cmd = f"dd if=/dev/random of={obj_img} bs=1M count=1"
    print("test.img 不存在，命令生成: ", cmd)
    os.system(cmd)
